package com.ruoyi.common.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.domain.Type_SegVo;
import com.ruoyi.common.service.IndexService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;


/**
 * 数据可视化接口
 * @author wad
 * @date 2022/4/30 9:46
 * @project RuoYi-YiQing
 **/
@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IndexService indexService;

    /**
     * 第一个图接口
     * @return
     */
    @GetMapping("/OneChartX")
    @ResponseBody
    public AjaxResult OneChartX(){
        Map<String,Object> map=new HashMap<>();
        String[] last12Months = DateUtils.getLast12Months();
        List<String> strings = Arrays.asList(last12Months);
        List<Integer> list = indexService.OneCharts();
        map.put("months",strings);
        map.put("tempData",list);
        return AjaxResult.success(map);
    }

    /**
     * 第二个图接口
     * @return
     */
    @GetMapping("/twoChart")
    @ResponseBody
    public AjaxResult twoChart(){
        Map<String,Object> map=new HashMap<>();
        String[] last12Months = DateUtils.getLast12Months();
        List<String> strings = Arrays.asList(last12Months);
        List<Integer> list = indexService.TwoCharts();
        map.put("months",strings);
        map.put("tempData",list);
        return AjaxResult.success(map);
    }

    /**
     * 第三个图接口
     * @return
     */
    @GetMapping("/threeChart")
    @ResponseBody
    public AjaxResult threeChart(){
        Map<String,Object> map=new HashMap<>();
        String[] last12Months = DateUtils.getLast12Months();
        List<String> strings = Arrays.asList(last12Months);
        List<Integer> list = indexService.threeCharts();
        map.put("months",strings);
        map.put("tempData",list);
        return AjaxResult.success(map);
    }

    /**
     * 第五张图接口
     * @return
     */
    @GetMapping("/fiveChart")
    @ResponseBody
    public AjaxResult fiveChart(){
        Map<String,Object> map=new HashMap<>();
        List<Integer> list1 = indexService.fiveChart1();
        List<Integer> list2 = indexService.fiveChart2();
        List<Integer> list3 = indexService.fiveChart3();
        String[] last7Days = DateUtils.getLast7Days();
        List<String> strings = Arrays.asList(last7Days);
        map.put("tempData1",list1);
        map.put("tempData2",list2);
        map.put("tempData3",list3);
        map.put("days",strings);
        return AjaxResult.success(map);
    }

    /**
     * 第四张图接口
     * @return
     */
    @GetMapping("/fourChart")
    @ResponseBody
    public AjaxResult fourChart()
    {
        List<Type_SegVo> list=new ArrayList<>();
        list.add(indexService.fourChart1());
        list.add(indexService.fourChart2());
        list.add(indexService.fourChart3());
        return AjaxResult.success(list);
    }

}
